<?php
namespace app\api\service\server;

use app\exceptions\OrdinaryException;
use TencentCloud\Common\Credential;
use TencentCloud\Common\Exception\TencentCloudSDKException;
use TencentCloud\Cvm\V20170312\CvmClient;
use TencentCloud\Cvm\V20170312\Models\DescribeZonesRequest;

/**
 * Tencentcloud Service
 * User: zng
 * Date: 2020/03/04
 * Time: 16:25
 */
class Tencentcloud {

    /**
     * 获取腾讯云授权包
     *
     * @return string
     */
    public function getAuthorization()
    {
        try{
            $cred = new Credential(config('tencentcloud.secretId'), config('tencentcloud.secretKey'));
            $client = new CvmClient($cred, 'ap-shanghai');
            $req = new DescribeZonesRequest();
            return $client->DescribeZones($req);
        } catch ( TencentCloudSDKException $exception ) {
            throw new OrdinaryException($exception);
        }

    }

}